<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/5/19
  Time: 16:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>

<div class="panel">
<form id="form_personneluse_input" class="panel-body form-horizontal form-padding">
  <input type="hidden" name="keyId" id="keyId" value="${personnelUse.id}" />
  <input type="hidden" name="parentId" id="parentId" value="${parentId}" />
  <input type="hidden" name="curDutyId" id="curDutyId" value=""/>

  <div class="form-group">
    <label class="col-md-2 control-label">用人性质<i class="fa fa-asterisk txt-color-red"></i>
      <span id="natureSpan" style="display: none">${personneluse.nature}</span>
    </label>
    <div class="col-md-6">

      <div class="radio">
        <!-- Inline radio buttons -->
        <input type="radio" name="nature" id="nature1Selected" class="magic-radio" value="1"
        <c:if test="${personnelUse.nature eq 1}"> checked="checked"</c:if> >
        <label for="nature1Selected">正式</label>

        <input type="radio" name="nature" id="nature2Selected" class="magic-radio" value="2"
        <c:if test="${personnelUse.nature eq 2}"> checked="checked"</c:if> >
        <label for="nature2Selected">试用</label>

      </div>
    </div>
  </div>

  <div class="form-group">
    <label class="col-md-2 control-label">薪资<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-6">
      <input type="number" id="salary" name="salary" class="form-control" placeholder="请输入薪资（元）" value="${personnelUse.salary}">
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">合同开始日期<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-2">
      <div class="input-group date">
        <input type="text" class="form-control" id="contractDateStart" name="contractDateStart" placeholder="请选择合同开始日期"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${personnelUse.contractDateStart}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
    <label class="col-md-2 control-label">合同结束日期<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-2">
      <div class="input-group date">
        <input type="text" class="form-control" id="contractDateEnd" name="contractDateEnd" placeholder="请选择合同结束日期"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${personnelUse.contractDateEnd}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>

  <div class="form-group div-Hidden">
    <label class="col-md-2 control-label">试用开始日期<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-2">
      <div class="input-group date">
        <input type="text" class="form-control" id="trialDateStart" name="trialDateStart" placeholder="请选择试用开始日期"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${personnelUse.trialDateStart}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
    <label class="col-md-2 control-label">试用结束日期<i class="fa fa-asterisk txt-color-red"></i></label>
    <div class="col-md-2">
      <div class="input-group date">
        <input type="text" class="form-control" id="trialDateEnd" name="trialDateEnd" placeholder="请选择试用结束日期"
               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${personnelUse.trialDateEnd}" /> >
        <span class="input-group-addon"><i class="ti-calendar"></i></span>
      </div>
    </div>
  </div>


  <div class="form-group">
    <label class="col-md-2 control-label">提交人</label>
    <div class="col-md-2">
      <p class="form-control-static">${personnelUse.creater.name}</p>
    </div>
    <label class="col-md-2 control-label">提交日期</label>
    <div class="col-md-2">
      <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${personnelUse.createTime}" /></p>
    </div>
  </div>

  <div class="panel-footer">
    <a class="btn btn-default" id="apply-re-common3" href="javascript:void(0)">
      <i class="fa fa-lg fa-mail-reply"></i> 返回
    </a>
    <a class="btn btn-success" id="btn-save-common3" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存 </a>
    <c:if test="${personnelUse==null || personnelUse.processState=='Draft'}">
      <a class="btn btn-warning" id="btn-commit-common3" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交 </a>
    </c:if>
    <c:if test="${personnelUse!=null && personnelUse.processState=='Backed'}">
      <a class="btn btn-warning" id="btn-recommit-common2" href="javascript:void(0);"><i class="fa fa-upload"></i> 再提交 </a>
    </c:if>
  </div>

</form>
  </div>
<!--===================================================-->
<!-- END BASIC FORM ELEMENTS -->


<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";

  $(function(){
    var pdata= {
      keyId:$("#form_personneluse_input #keyId").val(),
      entityName:"com.fz.us.oa.core.entity.com.PersonnelUse"
    };
    multiDuty(pdata);
//    fn_dispatch_input_validate()
  });


  // 日期选择
  $('.input-group.date').datepicker({
    format: 'yyyy-mm-dd',
    weekStart: 1,
    autoclose: true,
    todayBtn: 'linked',
    todayHighlight: true,
    language: 'zh-CN'
  });

  //校验
  function infoValidate() {
    var tmp = "";

    tmp = $('input:radio[name="nature"]:checked').val();
    if(!tmp){
      __toastr_error("请选择用人性质！");
      return false;
    }

    tmp = $("input#salary").val();
    if(!tmp){
      __toastr_error("请输入薪资！");
      return false;
    }

    tmp = $("input#contractDateStart").val();
    if(!tmp){
      __toastr_error("请选择合同开始日期！");
      return false;
    }

    tmp = $("input#contractDateEnd").val();
    if(!tmp){
      __toastr_error("请选择合同结束日期！");
      return false;
    }

    tmp = $("input#trialDateStart").val();
    if(!tmp){
      __toastr_error("请选择试用开始日期！");
      return false;
    }

    tmp = $("input#trialDateEnd").val();
    if(!tmp){
      __toastr_error("请选择试用结束日期！");
      return false;
    }

    return true;
  }

  //保存
  $("#btn-save-common3").click(
          function(e) {
            __confirm_dialog("提示：","确定保存吗？",
                    function () {
                      __form_save("form_personneluse_input", "<%=path%>/com/personnelUse/save",function(){
                        $("#apply-re-common3").trigger("click");
                      });
                    }
            )
          }
  );

  //提交
  $("#btn-commit-common3,#btn-recommit-common3").click(
          function(e) {
            var $valid = infoValidate();
//                console.log("v:"+$valid);
            if(!$valid) return false;

            __confirm_dialog("提示：","提交后填写资料不得修改，请确认是否进行提交？",
                    function () {
                      __form_save("form_personneluse_input", "<%=path%>/com/personnelUse/submit",function(){
                        $("#apply-re-common3").trigger("click");
                      });
                    }
            )
          }
  );

  //返回视图
  $("#apply-re-common3").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      returnToHashUrl()
    }
  });

</script>